<template>
  <div class="container" @click="handleGalleryClose">
    <div class="wrapper">
      <swiper :options="swiperOption">
        <swiper-slide 
        v-for="(item, index) in imgList"
        :key="index"
        >
          <img 
          class="gallery-img"
          :src="item" alt="">
        </swiper-slide>
        <div class="swiper-pagination"  slot="pagination"></div> -->
      </swiper>
    </div>
  </div>
</template>
<script>
export default {
  name: "CommonGallery",
  props: {
    imgList: Array,
    default() {
      return [];
    }
  },
  methods: {
    handleGalleryClose() {
      this.$emit("close");
    }
  },
  data() {
    return {
      swiperOption: {
        pagination: ".swiper-pagination",
        paginationType: "fraction",
        observer: true,
        // 当父元素发生变化的时候, 会自动刷新 处理划不动的问题
        observeParents: true
      }
    };
  }
};
</script>
<style lang="stylus" scoped>
.container >>> .swiper-container {
  overflow: inherit;
}

.container {
  z-index: 99;
  width: 100%;
  position: fixed;
  top: 0;
  bottom: 0;
  right: 0;
  left: 0;
  background-color: #000;
  display: flex;
  flex-direction: column;
  justify-content: center;

  .gallery-img {
    width: 100%;
  }

  .wrapper {
    .swiper-pagination {
      color: #fff;
      bottom: -1rem;
    }
  }
}
</style>
